# Contributor: Myautsai PAN <myautsai@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=openconnect
pkgver=9.01
pkgrel=0
pkgdesc="Open client for Cisco AnyConnect VPN"
url="https://www.infradead.org/openconnect/"
arch="all"
license="LGPL-2.1-or-later"
depends="vpnc iproute2"
makedepends="autoconf automake intltool openssl1.1-compat-dev libxml2-dev
	krb5-dev lz4-dev libproxy-dev linux-headers stoken-dev
	pcsc-lite-dev oath-toolkit-dev python3-dev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-openrc $pkgname-bash-completion"
source="ftp://ftp.infradead.org/pub/openconnect/openconnect-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	"

build() {
	./configure \
		--prefix=/usr \
		--sbindir=/usr/bin \
		--disable-static \
		--disable-rpath \
		--with-openssl \
		--with-stoken \
		--with-vpnc-script=/etc/vpnc/vpnc-script \
		--disable-nls
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
	mkdir -p "$pkgdir"/var/log/openconnect
	mkdir -p "$pkgdir"/etc/openconnect
}

sha512sums="
b7428847a90f8ca9d1f1f61653c1f2486f0a07989f3b7435b746c5e901998194f4ee2b4f9569a548a23bba368bb1e9f273674c0759aac9df30208d2a6a303c34  openconnect-9.01.tar.gz
994a8100ef0618e22c5aa6c6ac517632ad16fd58f41abda8379f5cdca8a1ffd6eff5a4cc2d6464db60bf6cc3df1237696cbe055cf83b4c0ccfe77042baa7b1e2  openconnect.initd
a689df7141621c80bca77fdd1e01397b98882c7fd8db79b2fe1495916656522234e3af739538002533c003e4243e9af4bf80cd73bae961e15568997ce89ef6d5  openconnect.confd
3b269eb7f469343d48e6e3aa694c5c051811c217217bebf2e74d051cbacf2b57ba926ea69474d30937067f45100863188f719db3fa1bcb4862ddbf446bdd48d2  openconnect.logrotate
"
